<?php
header('Content-Type:text/html; Charset=UTF-8');
include 'lib/checker.php';

@$text = $_REQUEST['text'];

$personSelectSql = 'select id,name,imgUrl from person';

$personSqlWhere = " where name like concat('%',:text,'%')";

$personSelectData = array();

$personSqlOrder = ' order by id asc';

if(!empty($text)){
	$personSelectSql .= $personSqlWhere;
	$personSelectData['text'] = $text;
}

$personSelectSql .= $personSqlOrder;

require 'lib/db.php';
$persons = dbSelectAll($personSelectSql,$personSelectData);
include 'lib/header.php';
?>

    	<div class="panel panel-info">
    		<div class="panel-heading">
    			<div class="panel-title">联系人列表</div>
    		</div>
    		<div class="penel-body">
    				<?php foreach($persons as $person){?>
    					<a href="editPerson.php?pid=<?php echo $person['id']?>" class="list-group-item" >
    						<img src="imgs/<?php echo $person['imgUrl']?>" width="30" height="30">
    						&nbsp;
    						<?php echo $person['id'].'->'.$person['name']?>
    					</a>
    				<?php }?>
    		</div>
    	</div>
<?php include 'lib/footer.php';?>